package com.cddx.logistics.service.impl;


import com.cddx.logistics.domain.dto.SysDictItemQueryDTO;
import com.cddx.logistics.domain.pojo.SysDictItem;
import com.cddx.logistics.domain.vo.SysDictItemVO;
import com.cddx.logistics.mapper.SysDictItemMapper;
import com.cddx.logistics.service.SysDictItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class SysDictItemServiceImpl implements SysDictItemService {
    @Resource
    private SysDictItemMapper sysdictItemMapper;


    @Override
    public PageInfo<SysDictItemVO> queryPage(SysDictItemQueryDTO sysDictItemQueryDTO) {
        PageHelper.startPage(sysDictItemQueryDTO.getPage(),sysDictItemQueryDTO.getLimit());
        List<SysDictItemVO> sysdictVOList = sysdictItemMapper.queryPage(sysDictItemQueryDTO);
        PageInfo<SysDictItemVO> pageInfo = new PageInfo<>(sysdictVOList);
        return pageInfo;
    }

    @Override
    public boolean delete(Integer id) {
        return sysdictItemMapper.delete(id) > 0;
    }

    @Override
    public boolean add(SysDictItem sysDictItem) {
        sysDictItem.setCreateTime(new Date());
        sysDictItem.setUpdateTime(new Date());
        return sysdictItemMapper.add(sysDictItem) > 0;
    }

    @Override
    public boolean update(SysDictItem sysDictItem) {
        sysDictItem.setUpdateTime(new Date());
        return sysdictItemMapper.update(sysDictItem) > 0;
    }
}
